package com.bamboo.eduservice.controller;


import com.bamboo.commonutils.ResponseEntity;
import com.bamboo.eduservice.entity.EduVideo;
import com.bamboo.eduservice.service.EduVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author jack.wu
 * @since 2020-07-05
 */
@Api(description = "小节管理")
@RestController
@RequestMapping("/eduservice/video")
@CrossOrigin
public class EduVideoController {

    @Resource
    private EduVideoService videoService;

    @ApiOperation(value = "根据id查询小节")
    @GetMapping("info/{id}")
    public ResponseEntity getVideoInfo(@PathVariable String id) {
        EduVideo video = videoService.getById(id);
        return ResponseEntity.ok().data("video", video);
    }

    @ApiOperation(value = "添加小节")
    @PostMapping("add")
    public ResponseEntity addVideoInfo(@RequestBody EduVideo video) {
        videoService.save(video);
        return ResponseEntity.ok();
    }

    @ApiOperation(value = "修改小节")
    @PutMapping("update")
    public ResponseEntity updateVideoInfo(@RequestBody EduVideo video) {
        videoService.updateById(video);
        return ResponseEntity.ok();
    }

    @ApiOperation(value = "根据id删除小节")
    @DeleteMapping("delete/{id}")
    public ResponseEntity deleteVideoInfo(@PathVariable String id) {
        videoService.deleteVideoInfo(id);
        return ResponseEntity.ok();
    }

}

